package crawler_py;

import java.io.BufferedReader;
import java.io.InputStreamReader;

public class CrawlerRun {

    public static void crawlerRun(String order){
        if (!order.equals("tag") && !order.equals("list") && !order.equals("info")){
            System.err.println("order is not correct!");
            return;
        }
        try{
            System.out.println("starting python crawler...");
            String command = "python crawler_py/Doemax/crawler_run.py "+order;
            Process pr = Runtime.getRuntime().exec(command);

            BufferedReader in = new BufferedReader(new
                    InputStreamReader(pr.getInputStream()));
            String line;
            while ((line = in.readLine()) != null) {
                System.out.println(line);
            }
            in.close();
            pr.waitFor();
            System.out.println("end");
        } catch (Exception e){
            e.printStackTrace();
        }
    }



}
